﻿package  com.devilcat.ws{
	import com.devilcat.ws.Basicws;
	import com.worlize.websocket.*;
	import com.devilcat.dt.Gamedt;
	
	public class UserEventws extends Basicws{
		var mUid:int;
		public function UserEventws(uid:int) {
			super("iw-protocol");
			mUid=uid;
		}
		override function handleWebSocketOpen(event:WebSocketEvent):void
		{
			var pack:Object = new Object();
			pack.uid=mUid;
			pack.action="loaduserevent";
			var myJson:String = JSONString(pack);
			websocket.sendUTF(myJson);
		}
		override function handleWebSocketMessage(event:WebSocketEvent):void
		{
			if (event.message.type === WebSocketMessage.TYPE_UTF8)
			{	
				var dumpo:Object = JSONObject(event.message.utf8Data);
				Gamedt.Player.eventList=dumpo[0];
				Gamedt.MainUI.GameStart();
			}
			closeConnect();
		}

	}
	
}
